<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE root PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

		<div class="innerTitle">Lista de Bairros</div>

		<h:panelGroup styleClass="innerFilter" layout="block">

			<div class="innerTextFilter">Filtro</div>

			<h:inputText value="#{bairroBean.filter}"></h:inputText>

			<a4j:commandButton value="Pesquisar" action="#{bairroBean.search}" styleClass="button" reRender="popup"/>

			<a4j:commandButton value="Novo" action="#{bairroBean.prepareSave}" styleClass="button" reRender="popup"/>

			<rich:dataTable id="listaBairro" rowClasses="even,odd" value="#{bairroBean.entities}" var="bairro" rows="10">

				<rich:column sortBy="#{bairro.nome}">
					<f:facet name="header"><h:outputLabel value="Nome"/></f:facet>
					<h:outputText value="#{bairro.nome}"/>
				</rich:column>

				<rich:column sortBy="#{bairro.cidade.nome}">
					<f:facet name="header"><h:outputLabel value="Cidade"/></f:facet>
					<h:outputText value="#{bairro.cidade.nome}"/>
				</rich:column>

				<h:column>
					<f:facet name="header"><h:outputLabel value="Estado"/></f:facet>
					<h:outputText value="#{bairro.estado.nome}"/>
				</h:column>

				<h:column headerClass="link">
					<a4j:commandLink action="#{bairroBean.prepareUpdate}" reRender="popup">
						<h:graphicImage styleClass="link" alt="Alterar" url="/images/btn/update.png"/>
						<f:setPropertyActionListener target="#{bairroBean.entity}" value="#{bairro}"/>
					</a4j:commandLink>
				</h:column>

				<h:column headerClass="link">
					<a4j:commandLink action="#{bairroBean.delete}" reRender="popup">
						<h:graphicImage styleClass="link" alt="Excluir" url="/images/btn/delete.png"/>
						<f:setPropertyActionListener target="#{bairroBean.entity}" value="#{bairro}"/>
					</a4j:commandLink>
				</h:column>

	            <f:facet name="footer">
					<rich:datascroller renderIfSinglePage="false" reRender="listaBairro" />
	            </f:facet>

			</rich:dataTable>

		</h:panelGroup>

</ui:composition>